package com.shujia.mr.kqzl;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class kqzlReduce extends Reducer<Text, LongWritable,Text,LongWritable> {
    @Override
    protected void reduce(Text key, Iterable<LongWritable> values, Reducer<Text, LongWritable, Text, LongWritable>.Context context) throws IOException, InterruptedException {
        Long sum = 0L;
        for (LongWritable value : values) {
            sum += value.get();//监测点PM2.5的总和
        }
        //对于该监测点一天的总和求和后与24相除
        Long avg_PM25 = sum/24;
        context.write(key,new LongWritable(avg_PM25));
    }
}
